<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<!-- .breadcrumb -->
	</div>
	<!-- Main content -->
	<div class="page-content">
    	<div class="row">
    	    <div class="page-header">
    			<h1>充值订单列表</h1>
    		</div>
    		
            <input type="hidden" name="upid" id="upid" value=""/>
            <div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								
								<th>手机号</th>
                                <th>支付订单号</th>
                                <th>充值卡号</th>
								<th>数量（多少个月）</th>
                                <th>每月金额</th>
                                <th>折扣</th>
                                <th>支付状态</th>
                                <th>支付金额</th>
                                <th>充值进度</th>
                                <th>下单时间</th>
                                <th>操作</th>
                              
                               
							</tr>
						</thead> 
						<tbody>
						<?php if (isset($list)&&count($list)>0){
                            	foreach ($list as $app){
                            	?>
							<tr>
								
                                <td><p><?php echo $app['contact_name'];?></p></td>
                                <td><p><?php echo $app['order_no'];?></p></td>
                                <td><p><?php echo $app['fuel_card'];?></p></td>
                                <td><p><?php echo $app['fuel_month_num'];?></p></td>
                                <td><p><?php echo $app['fuel_per_month_price'];?></p></td>
								<td><p><?php echo $app['fuel_discount'];?></p></td>
                                <td><p><?php if($app['payment_status']==1){if($app['status']==7){echo'已退款';}else{echo '已支付';}}else{echo '未支付';}?></p></td>
                                <td><p><?php echo $app['order_price'];?></p></td>
                                <td><p><a href="<?php echo base_url().'admin/order/fuel_order_task/'.$app['id']?>">查看<?php if($app['error']):?><span style="color:red;">(充值异常)</span><?php endif;?></a></p></td>
                                <td><p><?php echo $app['create_time'];?></p></td>
                                <td><p>
								<?php if (!empty($app['refund'])){ ?>
									<a href="javascript:void(0)" onclick="cancelmodal('<?php echo $app['id'];?>')" data-toggle="modal" class="btn btn-danger btn-sm">退款</a>
								<?php } ?>
                                
                                <?php if (!empty($app['have_task'])){ ?>
									<a href="javascript:void(0)" onclick="javascript:if(confirm('是否终止未充值的任务')){window.location='<?php echo base_url().'admin/order/fuel_cancle_task/'.$app['id']?>'}" data-toggle="modal" class="btn btn-danger btn-sm">终止充值</a>
								<?php } ?>
                                </p></td>
    						</tr>
    						<?php }
                            }else{?>
                            <tr>
                            	<td colspan="10">无数据</td>
                            </tr>
                            <?php }?>
                            </tbody>
                         </table>
                     </div><!-- /.table-responsive -->
                     <div class="col-sm-12" id="page">
		<div class="modal-footer no-margin-top">
			<div class="pull-left record">
				共<?php echo $count;?>条记录
				</div>
            	<?php if (isset($page))echo $page;?>
		</div>
	  </div>
				</div>
                
            </div><!-- /.row -->
		</div><!-- /.page-content -->
	</div><!-- /.main-content -->
    <div id="cancelModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>订单进行退款后将无法恢复，已支付的金额会直接退回用户支付账户<br>确定要退款吗？</p>
			</div>
			<div class="modal-footer">
			  <input type="hidden" id="cancel_order_id" value="">
			  <a id="cancelbtn" href="#" onclick="cancel()" class="btn btn-danger">确定</a>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
   	<script>
    function cancelmodal(id){
			$("#cancel_order_id").val(id);
		    $('#cancelModal').modal('show');
		}
	function cancel(){
			$('#cancelModal').modal('hide');
			showLoading('退款中...');
			$.ajax( {
		        url:'<?php echo site_url("admin/order/cancel")?>',
		        data:{order_id:$('#cancel_order_id').val()},
		        type:'post',
		        cache:false,
		        dataType:'json',    
		        success:function(result) {
		        	hideLoading();
		        	if(result.ret == '200'){
		            	if(result.data.code == '0'){
		            		window.location.reload();
		            	}else{
		            		alert("退款失败:"+result.data.msg);
		            	}
		        		
					}else {
						alert("退款失败:"+result.msg);
					}
		        },
		        error : function() {
		        	hideLoading();
					alert("error");
		        }
			});
		}	
    </script>